using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using AFI.Speargun.Web.Models;
using AFI.Speargun.Web.Models.Validation;

namespace AFI.Speargun.Web.Controllers
{
    public partial class SystemController
    {
        //
        // GET: /System/IndexCurrency

        [Authorize]
        public ActionResult IndexCurrency()
        {
            return View(_service.ListCurrencies());
        }

        //
        // GET: /System/CreateCurrency

        [Authorize]
        public ActionResult CreateCurrency()
        {
            return View();
        }

        //
        // POST: /System/CreateCurrency

        [AcceptVerbs(HttpVerbs.Post)]
        [Authorize]
        public ActionResult CreateCurrency(Currency currency)
        {
            if (_service.CreateCurrency(currency))
                return RedirectToAction("IndexCurrency");
            return View();
        }

        //
        // GET: /System/EditCurrency/{id}

        [Authorize]
        public ActionResult EditCurrency(Guid id)
        {
            return View(_service.GetCurrency(id));
        }

        //
        // POST: /System/EditCurrency/{id}

        [AcceptVerbs(HttpVerbs.Post)]
        [Authorize]
        public ActionResult EditCurrency(Guid id, Currency currency)
        {
            currency.CurrencyId = id;

            if (_service.EditCurrency(currency))
                return RedirectToAction("IndexCurrency");
            return View(currency);
        }

        //
        // GET: /System/DeleteCurrency/{id}

        [Authorize]
        public ActionResult DeleteCurrency(Guid id)
        {
            return View(_service.GetCurrency(id));
        }

        //
        // POST: /System/DeleteCurrency/{id}

        [AcceptVerbs(HttpVerbs.Post)]
        [Authorize]
        public ActionResult DeleteCurrency(Guid id, Currency currency)
        {
            if (_service.DeleteCurrency(id))
                return RedirectToAction("IndexCurrency");
            return View(currency);
        }
    }
}
